class Contact < ApplicationRecord

  has_many :followup_records, class_name: "FollowupRecord", foreign_key: "contacts_id", dependent: :nullify
  belongs_to :company, class_name: "Company", foreign_key: "companies_id"

  validates :companies_id, presence: true
  validates :name, presence: true, length: { maximum: 20 }
  validates :gender, inclusion: { in: [0, 1, 2] }
  validates :dept_name, length: { maximum: 20 }
  validates :important_level, inclusion: { in: [0, 1, 2] }
  validates :tel_no, presence: true, length: { maximum: 11 }
  validates :phone_no, length: { maximum: 20 }
  validates :email, length: { maximum: 50 }
  validates :note, length: { maximum: 200 }

  default_scope { where("is_delete = 0") }

end
